home *** CD-ROM | disk | FTP | other *** search
/ Cream of the Crop 1 / Cream of the Crop 1.iso / DESQVIEW / DESQCOMM.ARJ / COMMPROG.TEC
Text File  |  1992-03-16  |  18KB  |  323 lines

  1. ID:CO Communications Programs and DESQview
  2. Quarterdeck Technical Note #237
  3. by Michael Bolton
  4. March 16, 1992
  5.  
  6. DESQview provides true multitasking on any DOS PC in the Intel 86 processor
  7. family, and on compatibles.  Users of communications software find this
  8. feature particularly appealing, since other work can be done while large files
  9. are being uploaded or downloaded.  The communications link remains unbroken
  10. without sacrificing the entire computer to the on-line session.
  11.  
  12. There are a number of considerations involved with using communications
  13. software under DESQview.  Many of these issues are complicated by the fact
  14. that communications technology, and all of the various parameters which
  15. surround it, can seem complex and obscure.
  16.  
  17.  
  18. Q. What are COM ports and IRQs?  How do they relate to each other?
  19.  
  20. A serial port is a piece of hardware which can be used to move information to
  21. and from the machine.  (When files or other forms of information are being
  22. transferred FROM a machine, that machine is said to be "uploading"; when files
  23. are being transferred TO a machine, that machine is "downloading".)  Unlike
  24. parallel ports, which move information eight bits at a time (as a multilane
  25. freeway moves cars), serial ports move data one bit at a time (as a single
  26. lane roadway).  The initial design specification for the IBM PC called for a
  27. single serial port, and this port was assigned a hardware Interrupt ReQuest
  28. line, or IRQ -- very simply, a means of notifying the processor that attention
  29. to a hardware device is required.  When an IRQ is asserted (or signalled), a
  30. processor interrupt, also known as a software interrupt, is called. 
  31. Essentially, whenever a program or a piece of hardware asserts an interrupt,
  32. it asks the processor to run a subroutine.   The processor runs a bit of code,
  33. called an "interrupt handler", and then returns to where it was before. In the
  34. case of a serial port that is receiving data, each byte coming into the serial
  35. port causes a processor interrupt to be generated.  The processor stops
  36. whatever it's doing and calls the interrupt handler, which inspects the data
  37. at the serial port, and performs the appropriate action.  In the case of
  38. high-speed communications (i.e., greater than 2400 bytes per second, or 2400
  39. bps), this can be happening on the order of tens of thousands of times a
  40. second.
  41.  
  42. Note that we have three things to keep track of here:  when something comes in
  43. through (1) a serial port, it signals the processor's attention via (2) an
  44. IRQ.  When the processor receives an IRQ, it executes a particular (3)
  45. software interrupt.
  46.  
  47. An interrupt of higher priority can take immediate precedence over one of
  48. lower priority; that is, an interrupt can interrupt another interrupt!  Other
  49. pieces of hardware -- the keyboard and the system timer -- were seen as being
  50. of potentially greater urgency than the communications port.  Consequently,
  51. they were given IRQ lines with lower numbers, indicating higher priority. 
  52. Here's where life begins to get a little miserable:  COM 1 was thus assigned
  53. to IRQ 4 at this time, and IRQ 4 was set up to call software interrupt 0C hex
  54. (12 decimal).  So: COM1, using IRQ4, calls INT 0C.
  55.  
  56. Closer to the release date of the original PC, the designers found that they
  57. had an IRQ line available, nothing to put on it, and at least a notion that it
  58. might be desirable to have two serial ports on the machine.  COM 2 was
  59. therefore planned.  The next free available IRQ was... IRQ 3 -- it had not yet
  60. been assigned to a piece of hardware, although it had been assigned a
  61. processor interrupt.  So:  COM 2 was assigned to IRQ 3, which calls INT 0Bh.
  62.  
  63.  
  64. Later still, with mice and modems proliferating, and adventurous users
  65. desiring more serial ports, the specs were augmented yet again.  Two more
  66. serial ports (named COM 3 and 4) were clearly necessary, but there were no
  67. Interrupt ReQuest lines available by which they could signal the processor
  68. that they needed attention.  Consequently, it was decided that COM 3 and COM 4
  69. would SHARE IRQs with COM 1 and COM 2.  That is COM 3 would be given IRQ 4,
  70. and COM 4 would be given IRQ 3.  The chart makes this a bit easier to see.
  71.  
  72. Serial Port     IRQ     INT Hex (Decimal)
  73. ===========     ===     =================
  74.   COM 1          4         0C    (12)
  75.   COM 2          3         0B    (11)
  76.   COM 3          4         0C    (12)
  77.   COM 4          3         0B    (11)
  78.  
  79. Note that it is possible to have a system configured differently.  Many I/O
  80. cards allow the user to associate communications ports with different IRQs.
  81. However, the above are the default settings and are quite typical.  For
  82. information on systems using more than two serial ports, you may require the
  83. services of a FOSSIL driver.  This allows serial ports and IRQs to be
  84. "multiplexed", or shared.  Information on FOSSIL drivers can be found on many
  85. bulletin board systems and in some books on online communications.
  86.  
  87.  
  88. Q. Does DESQview support serial communications programs?
  89.  
  90. As stated above, DESQview's support of multitasking makes it ideal for those
  91. who wish to do other things while downloading is going on.  DESQview fully
  92. supports high-speed communications, and provides a number of features for the
  93. special handling that communications programs require.
  94.  
  95. Q. How should DESQview be set up for communications?
  96.  
  97. A. "Setup DESQview" Settings
  98.  
  99. Several settings are worthy of note in your overall DESQview setup.  The most
  100. important two are found in the Setup DESQview / Advanced Options / Performance
  101. section.
  102.  
  103.  
  104. 1) Optimize Communications should be set to Y.  This rotates the priority of
  105.    the IRQs, which by default are given priority equivalent to their numbers.
  106.    (Recall that the system timer is on IRQ 0  -- the lowest number and highest
  107.    priority -- and the keyboard uses IRQ 1.)  When Optimize Communications is
  108.    set to Y, the priority of IRQs is rotated, such that IRQ 2 typically gets
  109.    top priority (unless there is a mouse attached), 3 is next, and so on, with
  110.    0 and 1 receiving relatively low priority.  When DESQview sees a mouse
  111.    attached to IRQ2, DESQview gives IRQ3 top priority, on the assumption that
  112.    the that if you want to optimize communications, you want the serial ports
  113.    to receive top priority.
  114.  
  115.  
  116.  
  117.    Optimize Communications can be set to a number as well; the
  118.    number represents the IRQ (NOT the serial port) which is to be receive the
  119.    greatest priority.
  120.  
  121.  
  122.    If you are having difficulties with a modem on COM1, for example, it
  123.    might be worthwhile setting Optimize Communications to 4 (for IRQ 4,
  124.    representing COM 1).  In this case, IRQ 4 will get top priority, IRQ
  125.    5 will be next, and so on.  Again, note that since the priority of
  126.    the interrupts is merely rotated, and not reordered, setting Optimize
  127.    Communications to 4 will give IRQ 4 the highest and IRQ 3 the lowest
  128.    priority.  This is ideal for systems on which the modem is on COM 1
  129.    (IRQ 4) and the mouse is on COM 2 (IRQ 3).  Without Optimize
  130.    Communications, note that, in this case, the mouse would actually
  131.    have higher priority than the modem!
  132.  
  133.    On a system with two modems -- one on COM 1 (IRQ 4) and the other on
  134.    COM 2 (IRQ 3), an Optimize Communications setting of 4 would be
  135.    terrible; IRQ 3 would drop to the bottom of the priority list, and
  136.    thus the modem attached to COM2 could lose some of the incoming data.
  137.  
  138. 2) It is important to make sure that the processor "sees" the
  139.    communications port frequently, since the bytes coming in to the
  140.    serial ports must be handled before the buffer on the communications
  141.    port overflows.
  142.  
  143.    DESQview allocates time to each program via "Clock Ticks".  A tick is
  144.    regulated by the system timer, which ticks 18.2 times every second,
  145.    regardless of the type of processor.  DESQview runs a foreground
  146.    application for n clock ticks, (where n is the setting under Setup
  147.    DESQview / Advanced Options / Performance / Clock Ticks / Foreground)
  148.    and runs EACH background application for the number of clock ticks
  149.    allocated to the background setting.  The time in which an
  150.    application runs is called a time slice.  An application is suspended
  151.    while other programs are running in their time slices.  (Naturally, a
  152.    program will not get a background time slice if it has been set not to
  153.    run in background.)
  154.  
  155.    As an example, assume that we have four processes running on our
  156.    machine, one of which is a communications program, and that
  157.    DESQview's clock ticks setting is at its default 9 and 3.  In this
  158.    case, the foreground application will have the processor's attention
  159.    for 9 ticks (9/18.2 seconds), and two background processes will have
  160.    3 ticks each (3/18.2 + 3/18.2 seconds), in between the 3 ticks
  161.    allocated to our communications program.  This means that our
  162.    communications program is getting the processor's attention once per
  163.    second, for about 1/6 of a second; thus, the processor is otherwise
  164.    occupied 5/6 of a second.  This is a long time for a communications
  165.    program to be absent from the processor's attention.  Bytes coming in
  166.    on the serial port can overflow the one-byte buffer in the standard
  167.    UART chip, thereby causing some bytes to be lost.  Depending on the
  168.    robustness of your communications software and the protocol it uses,
  169.    lost bytes will result in a delayed transfer while the errors are
  170.    corrected, corrupted files, or an aborted download.  The section
  171.    below on the 16550A UART will have more to say on this subject.
  172.  
  173.    In fact, the situation isn't usually quite as bad as all that, since
  174.    not every program takes its full slice all the time.  DESQview-aware
  175.    programs inform DESQview whenever they have finished a task, and can
  176.  
  177.  
  178.    therefore be suspended until there's more work to do.  Programs that
  179.    have been written with no particular consideration for DESQview, are
  180.    monitored while they are in the background -- when they do not have
  181.    access to the keyboard.  If such a program is waiting for keyboard
  182.    input, DESQview will abridge that program's time slice, and will not
  183.    switch back to it until that program is put to the foreground again.
  184.    And in fact, the situation is STILL better than the above might
  185.    suggest.  DESQview manages all of the interrupt request lines by
  186.    reprogramming the programmable interrupt controller chip.  When a
  187.    hardware interrupt is asserted, DESQview determines which process
  188.    needs urgent attention, and passes control to that program's
  189.    interrupt handler.  DESQview also prevents timer, mouse, and keyboard
  190.    interrupts from interfering while a communications interrupt is being
  191.    handled, thus giving your program time to catch up and manage the
  192.    incoming data.  If you have programs that are running in background,
  193.    they may be suspended temporarily to improve the smoothness of
  194.    communications; at the DESQview menu, type Rearrange / Tune
  195.    Performance / Runs in Background / No.  If, despite all this, data is
  196.    still coming in faster than it can be managed, adding a larger buffer
  197.    to your serial port might help; see the section on the 16550A UART
  198.    below.
  199.  
  200.  
  201. B. DVP Settings
  202.  
  203. Three settings in your program's DESQview Program Information File
  204. (accessed by the Change a Program Menu) are crucial for communications.
  205.  
  206. 1) A communications program must be set to use the serial ports.  If the
  207.    modem uses COM 1, Uses Serial Ports can be set to 1.  If the modem
  208.    uses COM 2, Uses Serial Ports can be set to 2.  If the modem is on
  209.    COM 3 or COM 4, or if you are at all unsure about which serial port
  210.    the modem is on, set Uses Serial Ports to Y.  See Quarterdeck
  211.    Technical Note #145 (COM3N4.TEC -- COM Ports and DESQview) for more
  212.    information on this.
  213.  
  214.    In a given window, DESQview can hide a port by setting its I/O port
  215.    address to 0, rather than to its actual address.
  216.  
  217.  When Uses Serial Ports is set to    DESQview hides the port address of
  218.  ================================    ==================================
  219.              1                                    COM 2
  220.              2                                    COM 1
  221.              N                               Both COM ports
  222.  
  223.    If a port is hidden in a given window, programs running in that
  224.    window should be unable to access that port.  An exception to this is
  225.    noted below, in the section headed "Programs that initialize the
  226.    serial ports".  DESQview never hides the port address of COM3 or COM4, 
  227.    regardless of the "Uses serial ports" setting.
  228.  
  229. 2) A communications program must be set to run in background.  Valid
  230.    settings for Runs in Background are Y, N, or blank.  If the field is
  231.    left blank, DESQview will continue to run a program in background if
  232.    Uses Serial Ports is set to Y.
  233.  
  234. 3) A communications program must be set not to swap out.  Valid settings
  235.    for Can be Swapped Out are Y, N, and blank, but a communications
  236.    program should be set explicitly not to swap out.  If the program is
  237.    swapped out, it will be suspended.  If it is suspended, at very least
  238.    data will be lost, and at worst, a system crash could result.
  239.  
  240. Other settings are important, too.
  241.  
  242. 1) As with all programs running under DESQview, allocating enough memory to
  243.    the program is important.  Many communications programs call on
  244.    external programs -- most often to use download protocols which are
  245.    not built-in to the program.  At the point where the external
  246.    protocol is called, the application will typically need more memory
  247.    than it has been using up to that point.  Take this into account when
  248.    allocating memory usage in the DESQview Change a Program Menu.
  249.  
  250. 2) Communications programs use "protocols" for file transfers -- these
  251.    are schemes which govern how the connected computers relate to each
  252.    other, how the information is organized, what error-checking routines
  253.    are going to be used, and so on.  Communications programs typically
  254.    support at least a few protocols directly, and often provide for
  255.    other protocols to be added externally.  What typically happens is
  256.    that such a program will allow the user to "shell out" to DOS
  257.    temporarily, and start a program which handles the file transfer with
  258.    the desired protocol.
  259.  
  260.    External protocols may cause a window to close prematurely if
  261.    Close on Exit is set to Y.  When an external protocol finishes a file
  262.    transfer, and issues a DOS Terminate Program call, DESQview may close
  263.    the window in which the communications program is running.  If you
  264.    are using an external protocol with your communications software and
  265.    the window closes after a file transfer, try setting Close on Exit
  266.    to N.  If you are using a batch file to load TSRs and a
  267.    communications program within a DESQview window, you will find that
  268.    the window remains open after the batch file has been completed; make
  269.    "exit" the last line of the batch file.
  270.  
  271. 3) A program which writes either graphics or text directly to screen must be
  272.    configured not to do so if it is to run in background without corrupting
  273.    the screen of foreground applications.
  274.  
  275.    a) The ideal is for a program to be "DESQview- or TopView aware".  Such
  276.       programs write directly to screen normally, but write to DESQview's own
  277.       video buffer when running under DESQview.
  278.  
  279.    b) Programs which write directly to screen often have configuration options
  280.       which alter this strategy. Settings of this kind are often referred to
  281.       as "uses DOS calls for screen writes" or "uses BIOS writes", or "do not
  282.       write directly to screen".
  283.  
  284.    c) DESQview 386 is QEMM-386 and DESQview running together on an 80386 or an
  285.       i486 processor.  Programs running under DESQview 386 can be
  286.       "virtualized"; that is, DESQview 386 will intercept and properly manage
  287.       the screen writes of programs that write directly to the video hardware.
  288.  
  289.    If none of these configurations is possible, there are two unpleasant
  290.    prospects.  The first is that the program must be suspended while it is in
  291.    background.  DESQview will suspend a background program that writes
  292.    directly to screen:
  293.  
  294.  
  295.    a) if "Runs in Background" is set to N or blank, AND 
  296.    b) if "Uses Serial Ports" is set to N.
  297.  
  298.    Suspending a communications program is unacceptable, since the essence
  299.    of a communications program is to exchange information continuously.
  300.    DESQview will therefore keep running a background program that
  301.    writes directly to screen:
  302.  
  303.    a) if "Runs in Background" is set to Y, OR
  304.    b) if "Runs in Background" is blank AND Uses Serial Ports is Set to 1, 2,
  305.       or Y
  306.  
  307. In this case, the program will continue to write directly to screen while in
  308. background, thus corrupting the display of foreground applications.  If you
  309. are not using DESQview 386, and if your program writes directly to the screen
  310. and cannot be dissuaded from doing so, you will be forced to tolerate the
  311. corrupted display or to change your communications software to a package that
  312. does not write directly to the screen or is DESQview-aware.  See the files
  313. DIRECTLY.TEC and VIRTUALI.TEC for more information on display and
  314. virtualization.
  315.  
  316.   ************************************************************************
  317.   *This technical note may be copied and distributed freely as long as it*
  318.   *is distributed in its entirety and it is not distributed for profit.  *
  319.   *         Copyright (C) 1991-2 by Quarterdeck Office Systems           *
  320.   ************************ E N D   O F   F I L E *************************
  321.  
  322.  
  323.